package com.xiaozhen.blog.utils;

/**
 * @create 2023-05-06 15:35
 */
public class RedisKeyUtils {

    private static final String SPLIT = ":"; // 分隔符

    private static final String PREFIX_ENTITY_LIKE = "like:entity"; // 实体（博客、评论）点赞的前缀

    private static final String PREFIX_KAPTCHA = "kaptcha"; // 验证码前缀

    private static final String PREFIX_TICKET = "ticket"; // 登录凭证前缀


    // 某个实体的赞
    // like:entity:entityType:entityId -> set(userId)
    public static String getEntityLikeKey(int entityType, Long entityId) {
        return PREFIX_ENTITY_LIKE + SPLIT + entityType + SPLIT + entityId;
    }

    // 登录验证码
    public static String getKaptchaKey(String owner) {
        return PREFIX_KAPTCHA + SPLIT + owner;
    }

    // 登录凭证
    public static String getTicketKey(String ticket) {
        return PREFIX_KAPTCHA + SPLIT + ticket;
    }
}
